package fia;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sempere
 */
public class towers {


        static InputStreamReader arxiu;
        static Integer tablero[][];
        static Integer restriccions[][];
        static Integer dimensio;

        public static boolean carrega(String ruta) throws FileNotFoundException, UnsupportedEncodingException {
            arxiu = new InputStreamReader(new FileInputStream(ruta), "UTF-8");
            return (arxiu != null);
        }

        public static String llig() throws IOException {
            String linea = "";
            int c = 0;

            c = arxiu.read();
            while (((char) c != '\n'&& (char)c!='\r') && c > 0) {
                if (c < 256) {
                    linea += (char) c;

                }
                c = arxiu.read();
            }
            return linea;
        }

        public static void main(String[] args) throws IOException{
            if(carrega("/home/sempere/NetBeansProjects/fia/src/fia/facil1.txt")){
                extrauInformacio();
            }
     

        }

    private static void extrauInformacio() throws IOException {
       String token[];
       String linia= llig();

       dimensio = Integer.parseInt(linia);
       tablero = new Integer[dimensio][dimensio];
       for(int i=0; i< dimensio; i++){
           linia = llig();
           token = linia.split("\\s");
           for(int j=0; j<token.length; j++){
               
               tablero[i][j] = Integer.parseInt(token[j]);
           }
          

       }
       restriccions = new Integer[4][dimensio];
        for(int i=0; i< 4; i++){
           linia = llig();
           token = linia.split("\\s");
           for(int j=0; j<token.length; j++){
               
               restriccions[i][j] = Integer.parseInt(token[j]);
           }
       }

       for(int i=0;i<dimensio;i++){
           for(int j=0; j<dimensio;j++){
               System.out.print(tablero[i][j]);
           }
           System.out.println(" ");
       }
       System.out.println("\\");
       for(int i=0;i<4;i++){
           for(int j=0; j<dimensio;j++){
               System.out.print(restriccions[i][j]);
           }
           System.out.println(" ");
       }
       System.out.println("Èxit");
    }

}